{% block content %}
{% load static %}
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>MobSF Static Analysis Report</title>
    <meta name="description" content="MobSF Report">
    {% if host_os == 'windows' %}
        <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
        <link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
    {% else %}
    <style>
    
      /* latin */
      @font-face {
        font-family: 'Open Sans';
        font-style: normal;
        font-weight: 400;
        font-display: swap;
        src: local('Open Sans Regular'), local('OpenSans-Regular'), url('{{base_url}}{% static 'fonts/Open_Sans/OpenSans-Regular.ttf' %}') format('truetype');
      }

      /* latin */
      @font-face {
        font-family: 'Oswald';
        font-style: normal;
        font-weight: 400;
        font-display: swap;
        src: local('Oswald'), local('Oswald'), url('{{base_url}}{% static 'fonts/Oswald/Oswald-Regular.ttf' %}') format('truetype');
      }
  </style>
  {% endif %}
  <link rel="stylesheet" href="{{base_url}}{% static "others/css/pdf_report.css" %}">
  <link rel="stylesheet" href="{{base_url}}{% static "adminlte/plugins/fontawesome-free/css/all.min.css" %}">
  </head>

  <body bgcolor="FFFFFF">
    <article id="cover">
      <div class="header">
        <img src="{{base_url}}{% static "img/mobsf_logo.png" %}" class="center logo" alt="MobSF Logo"/>
        <div class="htext">ANDROID STATIC ANALYSIS REPORT </div>
      </div>
      </br></br></br>
     <div class="app">
      <img class="center" id="icon" src="{% if icon_path %}{{dwd_dir}}{{icon_path}}{% else %}{{base_url}}{% static 'img/no_icon.png' %}{% endif %}" alt="app_icon"/>
     </div>
      <div class="center">
        <h1><i class="fab fa-android"></i> {% if app_name %}  {{ app_name }}  {% else %} {{ file_name }} {% endif %} {% if version_name %}  ({{version_name}}) {% endif %}</h1>
      </div>
     </br></br></br></br></br>
      <div class="container">
      <table class="basic no_border">
      <tr class="no_border">
        <td class="no_border"><h3>File Name:</h3></td>
        <td class="no_border"><h3>{{file_name}}</h3></td>
      </tr>
      <tr>
        <td class="no_border"><h3>Package Name:</h3></td>
        <td class="no_border"><h3>{{ package_name }}</h3></td>
      </tr>
      <tr>
        <td class="no_border"><h3>Scan Date:</h3></td>
        <td class="no_border"><h3>{{ timestamp }}</h3></td>
      </tr>
{% if app_type not in 'so' %}
      {% if average_cvss %}
      <tr>
        <td class="no_border"><h3>Average CVSS Score:</h3></td>
        <td class="no_border"><h3>
  
        {% if average_cvss > 6 %}
        <span class="danger">{{ average_cvss }} </span>
        {% elif average_cvss == 0 %}
        {{ average_cvss }}
        {% elif average_cvss >= 4 %}
        <span class="warning">{{ average_cvss }}</span>
        {% elif average_cvss < 4 %}
        <span class="success">{{ average_cvss }}</span>
        {% endif %}
        </h3></td>
      </tr>
      {% endif %}
      <tr>
        <td class="no_border"><h3> App Security Score:</h3></td>
        <td class="no_border">
        <h2> 
          {% if appsec.security_score < 30 %}
            <span class="danger">{{ appsec.security_score }}/100 (CRITICAL RISK)</span>
          {% elif appsec.security_score < 40 %}
            <span class="high">{{ appsec.security_score }}/100 (HIGH RISK)</span>
          {% elif appsec.security_score < 60 %}
            <span class="warning">{{ appsec.security_score }}/100 (MEDIUM RISK)</span>
          {% else %}
            <span class="success">{{ appsec.security_score }}/100 (LOW RISK)</span>
          {% endif %}
        </h2>
        </td>
      </tr>
      <tr>
        <td class="no_border"><h3> Grade:</h3></td>
        <td class="no_border">
        <h3> 
          <span class="grade" style="background: 
          {% if appsec.security_score < 30 %}
          #ff0018">F
          {% elif appsec.security_score < 40 %}
          #ffc107">C
          {% elif appsec.security_score < 60 %}
          #f4ff45">B
          {% else %}
          #28a745">A
          {% endif %}
          </span>
        </br>
        </h3>
        </td>
      </tr>
{% endif %}
      {% if trackers|key:"trackers" %}
        <tr>
          <td class="no_border"><h3>Trackers Detection:</h3></td>
          <td class="no_border"><h3><span {% if trackers.detected_trackers > 0 %} class="warning" {% endif %}>{{ trackers.detected_trackers }}/{{ trackers.total_trackers }}</span></h3></td>
        </tr>
      {% endif %}
      {% if virus_total and virus_total.items|length > 9 and 'request successfully queued' not in virus_total.verbose_msg %}
        <tr>
        <td class="no_border"><h3>VirusTotal Detection:</h3></td>
        <td class="no_border"><h3><span class="{% if virus_total.positives > 0 %}danger{% else %}success{% endif %}"> {{ virus_total.positives }}/{{ virus_total.total }}</span></h3></td>
      </tr>
      {% endif %}
    
    </table>
    {% if app_type not in 'so' %}
  </br></br>
</br></br>
</br></br>
</br></br>
</br></br>
</br></br>
</br></br>
</br></br>
</br></br>
    <h2><i class="fas fa-chart-pie mr-1"></i> FINDINGS SEVERITY</h2>
    <table class="basic tbl-white">
      <tr>
        <th class="td-high"><i class="fas fa-bug"> </i> HIGH</th>
        <th class="td-warning"><i class="fas fa-exclamation-triangle"> </i> MEDIUM</th>
        <th class="td-info"><i class="fas fa-info"> </i> INFO</th>
        <th class="td-success"><i class="fas fa-check"></i> SECURE</th>
        <th class="td-secondary"><i class="fab fa-searchengin"></i> HOTSPOT</th>
      </tr>
      <tr>
        <td class="td-high"><h2>{{ appsec.high | length}}</h2></td>
        <td class="td-warning"><h2>{{ appsec.warning | length}}</h2></td>
        <td class="td-info"><h2>{{ appsec.info | length}}</h2></td>
        <td class="td-success"><h2>{{ appsec.secure | length}}</h2></td>
        <td class="td-secondary"><h2>{{ appsec.hotspot | length}}</h2></td>
      </tr>
    </table>
      </div>
      
    </article>
  {% endif %}
    <article id="contents">

      
      <h2><i class="fas fa-box-open"></i> FILE INFORMATION</h2>

      <h5>File Name:</h5> {{ file_name }}</br>
      <h5>Size: </h5> {{ size }}</br>
      <h5>MD5:</h5> {{ md5 }}</br>
      <h5>SHA1:</h5> {{ sha1 }}</br>
      <h5>SHA256:</h5> {{ sha256 }}</br>
     
{% if app_type not in 'so' %}
      <h2><i class="fas fa-info"></i> APP INFORMATION</h2>

      <h5>App Name:</h5> {{ app_name }}</br>
      <h5>Package Name:</h5> {{ package_name }}</br>
      <h5>Main Activity:</h5> {{ main_activity }}</br>
      <h5>Target SDK:</h5> {{ target_sdk }}</br>
      <h5>Min SDK:</h5> {{ min_sdk }}</br>
      <h5>Max SDK:</h5> {{ max_sdk }}</br>
      <h5>Android Version Name:</h5> {{ version_name }}</br>
      <h5>Android Version Code:</h5> {{ version_code }}</br>
{% endif %}

{% if app_type not in 'jar,aar,so' %}
      <h2><i class="fas fa-th-large"></i> APP COMPONENTS </h2>

        <h5>Activities:</h5> {{ activities | length }}</br>
        <h5>Services:</h5> {{ services | length }}</br>
        <h5>Receivers:</h5> {{ receivers | length }}</br>
        <h5>Providers:</h5> {{ providers | length }}</br>
        <h5>Exported Activities:</h5> <span {% if exported_count.exported_activities > 0 %} class="danger" {% endif %}> {{ exported_count.exported_activities }}</span></br>
        <h5>Exported Services:</h5> <span {% if exported_count.exported_services > 0 %} class="danger" {% endif %}> {{ exported_count.exported_services }}</span></br>
        <h5>Exported Receivers:</h5> <span {% if exported_count.exported_receivers > 0 %} class="danger" {% endif %}> {{ exported_count.exported_receivers }}</span></br>
        <h5>Exported Providers:</h5> <span {% if exported_count.exported_providers > 0 %} class="danger" {% endif %}> {{ exported_count.exported_providers }}</span></br>
  {% endif %}
  {% if app_type not in 'so' %}
        <h2><i class="fa fa-certificate"></i> CERTIFICATE INFORMATION</h2>
        {% if certificate_analysis.certificate_info %}
        <div class="panel-body">
              <p class="wrapped-text">{{ certificate_analysis.certificate_info }}</p>
        </div>
      {% else %}
      <span class="danger">Failed to read Code Signing Certificate or none available.</span>
      {% endif %}
  {% endif %}
      {% if permissions %}
      <h2><i class="fa fa-list"></i> APPLICATION PERMISSIONS</h2>

            <table class="basic">
              <thead>
            <tr>
                <th>PERMISSION</th>
                <th>STATUS</th>
                <th>INFO </th>
                <th>DESCRIPTION</th>
              </tr>
            </thead>
            <tbody>
            {% for perm,desc in permissions.items %}
            <tr>
            <td>{{ perm }}</td>
            <td>
            {% if desc.status == 'dangerous' %}
              <span class="danger">dangerous</span>
            {% elif desc.status == 'normal' %}
              <span class="info">normal</span>
            {% elif desc.status == 'signatureOrSystem' %}
              <span class="warning">SignatureOrSystem</span>
            {% elif desc.status == 'signature' %}
              <span class="success">signature</span>
            {% elif desc.status == 'unknown' %}
              <span class="secondary">unknown</span>
            {% endif %}
            </td>
            <td>{{ desc.info }}</td>
            <td>{{ desc.description }}</td>
            </tr>
            {% endfor %}
            </tbody>
            </table>
      {% endif %}
      
       {% if virus_total and virus_total.items|length > 9 and 'request successfully queued' not in virus_total.verbose_msg %}
       <h2><i class="fas fa-spider"></i> VIRUSTOTAL SCAN</h2>
       <p> <h5>{{ virus_total.positives }} / {{ virus_total.total }}</h5> &nbsp; AVs found this file Malicious! </p>
            {% if virus_total.positives %}
          
                    <table class="basic">
                                    <thead>
                                        <tr>
                                            <th>AV</th>
                                            <th>DETECTION</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    {% for av_name,av_result in virus_total.scans.items %}
                                        {% if av_result.detected == True %}
                                            <tr>
                                                <td>
                                                    {{ av_name }}
                                                </td>
                                                <td>
                                                    <span class="danger">{{ av_result.result }}</span>
                                                </td>
                                          </tr>
                                        {% endif %}
                                    {% endfor %}
                               </tbody>
                    </table>
            {% endif %}
      {% endif %}
      {% if apkid and app_type not in 'jar,aar'%}
      <h2><i class="fas fa-fingerprint"></i> APKID ANALYSIS</h2>

       <table class="basic">
                  <thead>
                      <tr>
                          <th>FILE</th>
                          <th>DETAILS</th>
                      </tr>
                  </thead>
                  <tbody>
                      {% if apkid %}
                       {% for file, details in apkid.items %}
                       <tr>
                         <td>
                             {{file}}
                        </td>
                        <td>
                            <table class="basic">
                              <thead>
                                  <tr>
                                      <th>FINDINGS</th>
                                      <th>DETAILS</th>
                                  </tr>
                              </thead>
                            <tbody>
                            {% for detail, idens in details.items %}
                            <tr>
                              <td>
                               {% if detail == "anti_vm" %}
                               <span class="warning">Anti-VM Code</span>
                               {% elif detail == "anti_disassembly" %}
                               <span class="warning">Anti Disassembly Code</span>
                               {% elif detail == "anti_debug" %}
                               <span class="warning">Anti Debug Code</span>
                               {% elif detail == "compiler" %}
                               <span class="info">Compiler</span>
                               {% elif detail == "abnormal" %}
                               <span class="warning">Abnormal Code</span>
                               {% elif detail == "obfuscator" %}
                               <span class="warning">Obfuscator</span>
                               {% elif detail == "protector" %}
                               <span class="info">Protector</span>
                               {% elif detail == "packer" %}
                               <span class="danger">Packer Found</span>
                               {% elif detail == "dropper" %}
                               <span class="danger">Dropper Found</span>
                               {% elif detail == "manipulator" %}
                               <span class="warning">Manipulator Found</span>
                               {% else %}
                               <span class="info">{{detail}}</span>
                               {% endif %}
                            </td>
                              <td> {% for idn in idens %} {{ idn }}</br> {% endfor %}</td>
                            </tr>
                            {% endfor %}
                           </tbody>
                            </table>
                        </td>
                 
                        </tr>
                         {% endfor %}
                      {% else %}
                      <p align="center"><strong>APKiD not enabled.</strong></p>
                      {% endif %}
                    </tbody>
                    </table>
      {% endif %}
      {% if browsable_activities %}
      <h2><i class="fas fa-clone"></i> BROWSABLE ACTIVITIES</h2>
       <table class="basic">
                                        <thead>
                                            <tr>
                                                <th>ACTIVITY</th>
                                                <th>INTENT</th>   
                                            </tr>
                                        </thead>
                                        <tbody>
                      {% for activity,intent_details in browsable_activities.items %}
                          <tr>
                            <td>{{activity}}</td>
                            <td>
                                   {% if intent_details|key:"schemes" %}
                                      <strong>Schemes</strong>: 
                                      {% for scheme in intent_details|key:"schemes" %}
                                        {{scheme}},
                                      {% endfor %}
                                       </br>
                                   {% endif %}
                                   {% if intent_details|key:"hosts" %}
                                      <strong>Hosts:</strong> {% for host in intent_details|key:"hosts" %}
                                        {{host}},
                                      {% endfor %} 
                                      </br>
                                   {% endif %}
                                   {% if intent_details|key:"ports" %}
                                      <strong>Ports:</strong> {% for port in intent_details|key:"ports" %}
                                        {{port}},
                                      {% endfor %} 
                                      </br>
                                   {% endif %}
                                   {% if intent_details|key:"mime_types" %}
                                      <strong>Mime Types:</strong> {% for mime in intent_details|key:"mime_types" %}
                                        {{mime}},
                                      {% endfor %} 
                                      </br>
                                   {% endif %}
                                   {% if intent_details|key:"paths" %}
                                      <strong>Paths:</strong> {% for path in intent_details|key:"paths" %}
                                        {{path}},
                                      {% endfor %} 
                                      </br>
                                   {% endif %}
                                   {% if intent_details|key:"path_prefixs" %}
                                      <strong>Path Prefixes:</strong> {% for prefix in intent_details|key:"path_prefixs" %}
                                        {{prefix}},
                                      {% endfor %} 
                                      </br>
                                   {% endif %}
                                   {% if intent_details|key:"path_patterns" %}
                                      <strong>Path Patterns:</strong> {% for pattern in intent_details|key:"path_patterns" %}
                                        {{pattern}},
                                      {% endfor %} 
                                      </br>
                                   {% endif %}
                              {% endfor %}
                            </td>
                          </tr>
                    </tbody>
                    </table>
      {% endif %}
    {% if app_type not in 'so' %}
     <h2><i class="fas fa-lock"></i> NETWORK SECURITY</h2>
     {% if network_security and 'network_summary' in network_security and network_security.network_summary|length > 0 %}
     <span class="danger">HIGH: </span>
     <h5 class="description-header">{{ network_security.network_summary.high }}</h5> | 
     <span class="warning"></i> WARNING: </span>
     <h5 class="description-header">{{ network_security.network_summary.warning }}</h5> |
     <span class="info">INFO: </span>
     <h5 class="description-header">{{ network_security.network_summary.info }}</h5> |
     <span class="success">SECURE: </span>
     <h5 class="description-header">{{ network_security.network_summary.secure }}</h5>
   {% endif %}</br>
     <table class="basic">
        <thead>
            <tr>
              <th>NO</th>
              <th>SCOPE</th>
              <th>SEVERITY</th>
              <th>DESCRIPTION</th>
                    </tr>
                </thead>
                <tbody>
        {% if network_security and 'network_findings' in network_security %}
        {% for item in network_security.network_findings %}
          <tr>
            <td>{{ forloop.counter }}</td>
            <td>
              {% for url in item.scope %}
              {{ url }}</br>
            {% endfor %}
            </td>
            <td>
              {% if item.severity == "high" %}
                <span class="danger">high</span>
              {% elif item.severity == "secure" %}
                <span class="success">secure</span>
              {% elif item.severity == "info" %}
                <span class="info">info</span>
              {% elif item.severity == "warning" %}
                  <span class="warning">warning</span>
              {% endif %}
            </td>
            <td>
            {{item.description }}
            </td>
            </tr>
          {% endfor %}
          {% endif %}
        </tbody>
        </table>
       
      <h2><i class="fas fa fa-id-card"></i> CERTIFICATE ANALYSIS</h2>
      {% if certificate_analysis and 'certificate_summary' in certificate_analysis and certificate_analysis.certificate_summary|length > 0 %}
      <span class="danger">HIGH: </span>
      <h5 class="description-header">{{ certificate_analysis.certificate_summary.high }}</h5> | 
      <span class="warning"></i> WARNING: </span>
      <h5 class="description-header">{{ certificate_analysis.certificate_summary.warning }}</h5> |
      <span class="info">INFO: </span>
      <h5 class="description-header">{{ certificate_analysis.certificate_summary.info }}</h5>
    {% endif %}</br>
      <table class="basic">
        <thead>
            <tr>
                <th>TITLE</th>
                <th>SEVERITY</th>
                <th>DESCRIPTION</th>
            </tr>
        </thead>
        <tbody>
          {% if certificate_analysis and 'certificate_findings' in certificate_analysis %}
            {% for find in certificate_analysis.certificate_findings %}
            <tr>
            <td>{{ find.2 }}</td>
            <td>
            {% if find.0 == 'high' %}
              <span class="danger">high</span>
            {% elif find.0  == 'secure' %}
              <span class="success">secure</span>
            {% elif find.0  == 'warning' %}
              <span class="warning">warning</span>
              {% elif find.0  == 'info' %}
              <span class="info">info</span>
            {% endif %}
            </td>
            <td>{{ find.1 }}</td>
            </tr>
            {% endfor %}
          {% endif %}
        </tbody>
    </table>
   
    <h2><i class="fas fa-search"></i> MANIFEST ANALYSIS</h2>
    {% if manifest_analysis and 'manifest_summary' in manifest_analysis and manifest_analysis.manifest_summary|length > 0 %}
    <span class="danger">HIGH: </span>
    <h5 class="description-header">{{ manifest_analysis.manifest_summary.high }}</h5> | 
    <span class="warning"></i> WARNING: </span>
    <h5 class="description-header">{{ manifest_analysis.manifest_summary.warning }}</h5> |
    <span class="info">INFO: </span>
    <h5 class="description-header">{{ manifest_analysis.manifest_summary.info }}</h5> |
    <span class="disabled">SUPPRESSED: </span>
    <h5 class="description-header">{{ manifest_analysis.manifest_summary.suppressed }}</h5>
  {% endif %}</br>
     <table class="basic">
                    <thead>
                        <tr>
                            <th>NO</th>
                            <th>ISSUE</th>
                            <th>SEVERITY</th>
												    <th>DESCRIPTION</th>
                                </tr>
                            </thead>
                            <tbody>
                    {% if manifest_analysis and 'manifest_findings' in manifest_analysis %}
                    {% for item in manifest_analysis.manifest_findings %}
                    <tr>
                      <td>{{ forloop.counter }}</td>
                      <td>
                      {{item|key:"title" | safe}}
                      </td>
                      <td>

                        {% if item|key:"severity" == "high" %}
                          <span class="danger">high</span>
                        {% elif item|key:"severity" == "info" %}
                          <span class="info">info</span>
                        {% elif item|key:"severity" == "warning" %}
                          <span class="warning">warning</span>
                        {% endif %}
                       
                      </td>
                      <td>
                      {{item|key:"description"}}
                      </td>
 
                     </tr>
                     {% endfor %}
                     {% endif %}

										</tbody>
										</table>
                   
      <h2><i class="fas fa-code"></i> CODE ANALYSIS</h2>
      {% if code_analysis and 'summary' in code_analysis and code_analysis.summary|length > 0 %}
      <span class="danger">HIGH: </span>
      <h5 class="description-header">{{ code_analysis.summary.high }}</h5> | 
      <span class="warning"></i> WARNING: </span>
      <h5 class="description-header">{{ code_analysis.summary.warning }}</h5> |
      <span class="info">INFO: </span>
      <h5 class="description-header">{{ code_analysis.summary.info }}</h5> |
      <span class="success">SECURE: </span>
      <h5 class="description-header">{{ code_analysis.summary.secure }}</h5> |
      <span class="disabled">SUPPRESSED: </span>
      <h5 class="description-header">{{ code_analysis.summary.suppressed }}</h5>
    {% endif %}</br>
       <table class="basic">
                <thead>
                    <tr>
                        <th>NO</th>
                        <th>ISSUE</th>
                        <th>SEVERITY</th>
                        <th>STANDARDS</th>
                        <th>FILES</th>
                    </tr>
                </thead>
                <tbody>
                   {% if code_analysis and 'findings' in code_analysis %}
                   {% for rule, details in code_analysis.findings.items %}
                  <tr>
                  <td>{{ forloop.counter }}</td>
                  <td width="25%">
                    {% if details.metadata|key:"ref" %}
                    <a href="{{details.metadata.ref}}" target="_blank" rel="noopener"> {{ details.metadata.description }}</a>
                    {% else %}
                      {{ details.metadata.description }}
                    {% endif %}
                  </td>
                  <td>
                    {% if details.metadata.severity == "high" %}
                      <span class="danger">high</span>
                      {% elif details.metadata.severity == "good" %}
                      <span class="success">secure</span>
                      {% elif details.metadata.severity == "warning" %}
                      <span class="warning">warning</span>
                      {% elif details.metadata.severity == "info" %}
                      <span class="info">info</span>
                      {% endif %}
                  </td>
                  <td>
                    {% if average_cvss %}
                      <strong>CVSS V2:</strong>
                      {{ details.metadata.cvss }}
                      {% if details.metadata.cvss > 6 %}
                         <span class="danger"> (high)</span>
                      {% elif details.metadata.cvss == 0 %}
                        <span class="info">(info)</span>
                      {% elif details.metadata.cvss >= 4 %}
                        <span class="warning"> (medium)</span>
                      {% elif details.metadata.cvss < 4 %}
                        <span class="success"> (low)</span>
                      {% endif %}
                      </br>
                    {% endif %}
                      {% if details.metadata.cwe %}<strong>CWE: </strong>{{ details.metadata.cwe }}{% endif %}
                      {% if details.metadata|key:"owasp-mobile" %}</br> <strong>OWASP Top 10: </strong>{{ details.metadata|key:"owasp-mobile" }}{% endif %}
                      {% if details.metadata.masvs %}</br> <strong>OWASP MASVS: </strong>{{ details.metadata.masvs }}{% endif %}
                  </td>
                 <td style="word-break:break-all;">
                  {% for file_path in details.files %}
                    {{ file_path }}
                  <br/>
                  {% endfor %}
                  </td>
                </tr>    
              {% endfor %} 
              {% endif %}
          </tbody>
          </table>
    {% endif %}
            
     {% if binary_analysis  %}
      <h2><i class="fa fa-flag"></i> SHARED LIBRARY BINARY ANALYSIS</h2>

        <table class="basic">
                    <thead>
                      <tr>
                        <th>NO</th>
                        <th>SHARED OBJECT</th>
                        <th>NX</th>
                        <th>PIE</th>
                        <th>STACK CANARY</th>
                        <th>RELRO</th>
                        <th>RPATH</th>
                        <th>RUNPATH</th>
                        <th>FORTIFY</th>
                        <th>SYMBOLS STRIPPED</th>
                     </tr>
                    </thead>
                    <tbody>
                      {% if not binary_analysis %}
                        No Shared Objects found.
                      {% endif %}
                       {% for so in binary_analysis %}
                       <tr>
                        <td>{{ forloop.counter }}</td>
                        <td width="20%">{{so.name | relative_path}}</td>
                        <td style="vertical-align: top;"><b>{{so.nx.is_nx}}</b>
                          <br/>
                          <span class="{% if so.nx.severity == 'high' %}danger{% elif so.nx.severity == 'warning' %}warning{% else %}info{% endif %}">{{so.nx.severity}}</span>
                          <br/>{{so.nx.description}}</td>
                          <td style="vertical-align: top;"><b>{{so.pie.is_pie}}</b>
                            <br/>
                            <span class="{% if so.pie.severity == 'high' %}danger{% elif so.pie.severity == 'warning' %}warning{% else %}info{% endif %}">{{so.pie.severity}}</span>
                            <br/>{{so.pie.description}}</td>
                          <td style="vertical-align: top;"><b>{{so.stack_canary.has_canary}}</b>
                            <br/>
                            <span class="{% if so.stack_canary.severity == 'high' %}danger{% elif so.stack_canary.severity == 'warning' %}warning{% else %}info{% endif %}">{{so.stack_canary.severity}}</span>
                            <br/>{{so.stack_canary.description}}</td>
                        <td style="vertical-align: top;"><b>{{so.relocation_readonly.relro}}</b>
                              <br/>
                              <span class="{% if so.relocation_readonly.severity == 'high' %}danger{% elif so.relocation_readonly.severity == 'warning' %}warning{% else %}info{% endif %}">{{so.relocation_readonly.severity}}</span>
                              <br/>{{so.relocation_readonly.description}}</td>
                        <td style="vertical-align: top;"><b>{{so.rpath.rpath}}</b>
                          <br/>
                          <span class="{% if so.rpath.severity == 'high' %}danger{% elif so.rpath.severity == 'warning' %}warning{% else %}info{% endif %}">{{so.rpath.severity}}</span>
                          <br/>{{so.rpath.description}}</td>
                        <td style="vertical-align: top;"><b>{{so.runpath.runpath}}</b>
                          <br/>
                          <span class="{% if so.runpath.severity == 'high' %}danger{% elif so.runpath.severity == 'warning' %}warning{% else %}info{% endif %}">{{so.runpath.severity}}</span>
                          <br/>{{so.runpath.description}}</td>
                        <td style="vertical-align: top;"><b>{{so.fortify.is_fortified}}</b>
                          <br/>
                          <span class="{% if so.fortify.severity == 'high' %}danger{% elif so.fortify.severity == 'warning' %}warning{% else %}info{% endif %}">{{so.fortify.severity}}</span>
                          <br/>{{so.fortify.description}}</td>
                        <td style="vertical-align: top;"><b>{{so.symbol.is_stripped}}</b>
                          <br/>
                          <span class="{% if so.symbol.severity == 'high' %}danger{% elif so.symbol.severity == 'warning' %}warning{% else %}info{% endif %}">{{so.symbol.severity}}</span>
                          <br/>{{so.symbol.description}}</td>
                      </tr>
                       {% endfor %}
                  </tbody>
                    </table>
    {% endif %}
    {% if app_type not in 'so' %}
    <h2><i class="fa fa-id-badge"></i> NIAP ANALYSIS v1.3</h2>
    <table class="basic">
              <thead>
                  <tr>
                    <th>NO</th>
                    <th>IDENTIFIER</th>
                    <th>REQUIREMENT</th>
                    <th>FEATURE</th>
                    <th>DESCRIPTION</th>
                </tr>
              </thead>
              <tbody>
                {% for iden, details in niap_analysis.items %}
                  <tr>
                  <td>{{ forloop.counter }}</td>
                  <td>
                    <span class="{% if 'does not' in details.choice %} warning {% elif 'not in accordance' in details.choice %} danger {% else %} info {% endif %}"> {{ iden }}</span>
                  </td>
                   <td>
                   {{ details.class }}
                  </td>
                  <td>
                    {{ details.description }}
                   </td>
                   <td>
                    {{ details.choice }}
                   </td>
                </tr>    
              {% endfor %} 
            </tbody>
          </table>
    {% endif %}

    {% if behaviour %}
    <h2><i class="fas fa-sitemap"></i> BEHAVIOUR ANALYSIS</h2>
    <table class="basic">
      <thead>
        <tr>
          <th>RULE ID</th>
          <th>BEHAVIOUR</th>
          <th>LABEL</th>
          <th>FILES</th>
      </tr>
      </thead>
      <tbody>
          {% for rule, details in behaviour.items %}
          <tr>
          <td>{{ rule }}</td>
          <td width="25%">
            {{ details.metadata.description }}
          </td>
          <td> {% for lbl in details.metadata.label %} 
            <span class="warning">{{ lbl }}</span>
          {% endfor %}
          </td>
          <td style="word-break:break-all;">
            {% for file_path in details.files %}
              {{ file_path }}
            <br/>
            {% endfor %}
          </td>
        </tr>    
      {% endfor %}
  </tbody>
  </table>
  {% endif %}

  {% if firebase_urls %} 
  <h2><i class="fas fa-database"></i> FIREBASE DATABASES ANALYSIS</h2>
        <table class="basic">
              <thead>
              <tr>
                <th>TITLE</th>
                <th>SEVERITY</th>
                <th>DESCRIPTION</th>
              </tr>
            </thead>
        <tbody>
              {% for find in firebase_urls %}
              <tr>
                <td>{{ find.title }}</td>
                <td>
                {% if find.severity == 'high' %}
                <span class="danger">high</span>
                {% elif find.severity  == 'secure' %}
                  <span class="success">secure</span>
                {% elif find.severity  == 'warning' %}
                  <span class="warning">warning</span>
                {% elif find.severity  == 'info' %}
                <span class="info">info</span>
                {% endif %}
                </td>
                <td>{{ find.description }}</td>
                </tr>
              {% endfor %} 
                </tbody>
                </table>
    {% endif %}

    {% if malware_permissions %}
    <h2><i class="fa fa-braille"></i> ABUSED PERMISSIONS</h2>

    <table id="table_ofac" class="table table-bordered table-hover table-striped">
      <thead>
      <tr>
         <th>TYPE</th>
         <th>MATCHES</th>
         <th>PERMISSIONS</th>
      </tr>
     </thead>
     <tbody>
      <tr>
        <td>Malware Permissions</td>
        <td>{{ malware_permissions.top_malware_permissions | length}}</b>/{{malware_permissions.total_malware_permissions}}</td>
        <td>
          {{ malware_permissions.top_malware_permissions | join:", "}}
      </td>
      </tr>
      <tr>
        <td>Other Common Permissions</td>
        <td>{{ malware_permissions.other_abused_permissions | length}}</b>/{{malware_permissions.total_other_permissions}}</td>
        <td>
          {{ malware_permissions.other_abused_permissions | join:", "}}
      </td>
      </tr>
    </tbody>
</table>
    <hr>
    <p>
      <h3>Malware Permissions:</h3> Top permissions that are widely abused by known malware. 
      <br/>
      <h3>Other Common Permissions:</h3> Permissions that are commonly abused by known malware. 
    </p>
      {% endif %}
            
 <!-- ===========================end malware permissions  ================================== -->

      {% if domains  %}
      <h2><i class="fa fa-exclamation"></i> OFAC SANCTIONED COUNTRIES</h2>
      <p>This app may communicate with the following OFAC sanctioned list of countries.</p>
      <table id="table_ofac" class="table table-bordered table-hover table-striped">
           <thead>
           <tr>
              <th>DOMAIN</th>
              <th>COUNTRY/REGION</th>
           </tr>
          </thead>
          <tbody>
          {% for domain, details in domains.items %}
          {% if details|key:"ofac" == True %}
           <tr><td>{{domain}}</td>
           <td>
             <strong>IP: </strong>{{details|key:"geolocation"|key:"ip"}}  <br/>
             <strong>Country: </strong>{{details|key:"geolocation"|key:"country_long"}} <br/>
             <strong>Region: </strong>{{details|key:"geolocation"|key:"region"}} <br/>
             <strong>City: </strong>{{details|key:"geolocation"|key:"city"}} <br/>
           </td>
           </tr>
           {% endif %}
           {% endfor %}
         </tbody>
     </table>

      <h2><i class="fab fa-searchengin"></i> DOMAIN MALWARE CHECK</h2>
         <table  class="basic">
                  <thead>
                  <tr>
                     <th>DOMAIN</th>
                     <th>STATUS</th>
                     <th>GEOLOCATION</th>
                  </tr>
                 </thead>
                 <tbody>
                 {% for domain, details in domains.items %}
                  <tr><td>{{domain}}</td><td> 

                    {% if details|key:"bad" == "yes" %}
                    <span class="danger">malware</span><br/>
             
                      <h5>URL: </h5> {{details|key:"domain_or_url"}}
                      <h5>IP: </h5> <span class="danger">{{details|key:"ip"}}</span>
                      <h5>Description: </h5> {{details|key:"desc"}}
                   
                  {% else %}
                    <span class="success">ok</span><br/>
                  {% endif %}
                  </td>
                  <td>
                    {% if details|key:"geolocation" %}
                
                      <h5>IP: </h5> {{details|key:"geolocation"|key:"ip"}}  <br/>
                      <h5>Country: </h5> {{details|key:"geolocation"|key:"country_long"}} <br/>
                      <h5>Region: </h5> {{details|key:"geolocation"|key:"region"}} <br/>
                      <h5>City: </h5> {{details|key:"geolocation"|key:"city"}} <br/>
                      <h5>Latitude: </h5> {{details|key:"geolocation"|key:"latitude"}} <br/>
                      <h5>Longitude: </h5> {{details|key:"geolocation"|key:"longitude"}} <br/>
                      <h5>View: </h5> <a target="_blank" href="http://maps.google.com/maps?q={{details|key:"geolocation"|key:"latitude"}},{{details|key:"geolocation"|key:"longitude"}}">Google Map</a>
                    {% else %}
                    No Geolocation information available.
                    {% endif %}
                  </td>
                  </tr>
                  {% endfor %}
                </tbody>
            </table>
      {% endif %}
<!-- Display urls only for so files-->
{% if app_type in 'so' %}
       {% if urls %} 
      <h2><i class="fas fa-globe"></i> URLS </h2>
      <table class="basic">
                  <thead>
                  <tr>
                     <th>URL</th>
                     <th>FILE</th>
                  </tr>
                 </thead>
                  <tbody>
									{% for urldict in urls %}
                    <tr>
                       <td style="word-break:break-all;">
                       {% for u in urldict|key:"urls" %}
                         {{ u }} </br>
                       {% endfor %}
                        </td>
                       <td style="word-break:break-all;">
                         {{urldict|key:"path"}}
                       </td>
                    </tr>
                  {% endfor %} 
										</tbody>
										</table>
        {% endif %}
{% endif %}
      {% if emails %}
      <h2><i class="fas fa-envelope"></i> EMAILS</h2>
          <table class="basic">
                  <thead>
                  <tr>
                     <th>EMAIL</th>
                     <th>FILE</th>
                  </tr>
                 </thead>
                  <tbody>
									{% for email_dict in emails %}
                    <tr>
                       <td style="word-break:break-all;">
                       {% for em in email_dict|key:"emails" %}
                         {{ em }} </br>
                       {% endfor %}
                        </td>

                       <td style="word-break:break-all;">
                         {{email_dict|key:"path"}}
                       </td>
                    </tr>
                  {% endfor %} 
										</tbody>
										</table>
      {% endif %}

  
      {% if trackers|key:"trackers" %}
      <h2><i class="fas fa-user-secret"></i> TRACKERS</h2>
       <table class="basic">
            <thead>
                <tr>
                    <th>TRACKER</th>
                    <th>CATEGORIES</th>
                    <th>URL</th>
                </tr>
            </thead>
          
            <tbody>
              {% for trk in trackers|key:"trackers" %}
              <tr>
                <td>
                  {{trk.name}}
                </td>
                <td>
                  {{trk.categories}}
                </td>
                <td>
                  <a target="_blank" href="{{trk.url}}" rel="noopener noreferrer">{{trk.url}}</a>
                </td>
              </tr>
              {% endfor %}
            </tbody>
        </table>
         {% endif %}
    
        {% if secrets %}
        <h2><i class="fas fa-key"></i> HARDCODED SECRETS</h2>
            <table class="basic">
                    <thead>
                    <tr>
                      <th>POSSIBLE SECRETS</th>
                    </tr>
                  </thead>
                    <tbody>
                    {% for sec in secrets %}
                      <tr>
                        <td style="word-break:break-all;">
                        {{ sec }}
                          </td>
                      </tr>
                    {% endfor %} 
                      </tbody>
                      </table>
        {% endif %}

        <!--Only for so-->
        {% if app_type in 'so' %}
        <h2><i class="fa fa-th"></i> SYMBOLS</h2>
            <table class="basic">
                    <tbody>
                    {% for val in file_analysis %}
                      <tr>
                        <td style="word-break:break-all;">
                        {{ val }}
                          </td>
                      </tr>
                    {% endfor %} 
                      </tbody>
                      </table>
       {% endif %}

     {% if not playstore_details.error %}
    <h2><i class="fab fa-google-play"></i> PLAYSTORE INFORMATION </h2>

                  <p>                                       
                    <h5>Title:</h5> 
                    {{ playstore_details.title }}
                  </p>
                  <p>                                       
                    <h5>Score:</h5> 
                  {{ playstore_details.score}}

                   <h5>Installs:</h5> 
                    {{ playstore_details.installs }}

                   <h5>Price:</h5> 
                      {{ playstore_details.price }}

                   <h5>Android Version Support:</h5> 
                    {{ playstore_details.androidVersionText }}
                   
                    <h5>Category:</h5> 
		                {{ playstore_details.genre }}

                    <h5>Play Store URL:</h5> 
                      <a target="_blank" href="{{ playstore_details.url }}" rel="noopener noreferrer"> {{ package_name }} </a>
                  </p>
                  
                  <p>
                  <h5>Developer Details:</h5> 
                      {{playstore_details.developer}},  
                      {{playstore_details.developerId}}, 
                      {{playstore_details.developerAddress }},
                      {{playstore_details.developerWebsite}}, 
                      {{playstore_details.developerEmail}}, 
                  </p>
		              <p>
                  <h5>Release Date:</h5> 
                   {{ playstore_details.released }}
		               <h5>Privacy Policy:</h5> 
                   <a target="_blank" href="{{ playstore_details.privacyPolicy }}" rel="noopener noreferrer">Privacy link</a>
		            </p>
                 <p>                                       
                      <h5>Description:</h5> 
                      <p>{{ playstore_details.description }}</p>
                  </p>
             
       {% endif %}
       <h2><i class="fas fa-list"></i> SCAN LOGS</h2>
    <table id="scan_logs" class="basic">
      <tr>
          <th>Timestamp</th>
          <th>Event</th>
          <th>Error</th>
      </tr>
  <tbody>
    {% for log in logs %}
    <tr>
      <td>
        {{log.timestamp}}
      </td>
      <td>
        {{log.status}}
      </td>
      <td>
        {% if not log.exception %}
        <p class="text-success">
          OK
        </p>
        {% else %}
        <p class="text-danger">
        {{log.exception}}
         </p>
        {% endif %}
      </td>
    </tr>
    {% endfor %}
  </tbody>
  </table>
</article>
    <article id="columns">
      </br>
      <hr>
      <h3>Report Generated by - MobSF {{ version }} </h3>
      <section>
        <p>
          Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing, malware analysis and security assessment framework capable of performing static and dynamic analysis.
        </p>
        <p>
        <strong>© {% now "Y" %} Mobile Security Framework - MobSF | <a href="https://ajinabraham.com">Ajin Abraham</a> | <a href="https://opensecurity.in">OpenSecurity</a>.</strong>
      </p>
      </section>
    </article>
  </body>
</html>
{% endblock %}
